Skip to content

fix(malachite): tighten proposal validation bounds#5514

Open
ukint-vs wants to merge 8 commits into
masterfrom
vs/malachite-bounded-fixes
Open

fix(malachite): tighten proposal validation bounds#5514
ukint-vs wants to merge 8 commits into
masterfrom
vs/malachite-bounded-fixes

Conversation

@ukint-vs
Copy link
Copy Markdown
Member

@ukint-vs ukint-vs commented May 25, 2026

Addresses the bounded-memory proposal-validation portion of #5473.

Summary

  • Adds bounded Malachite proposal-part stream reassembly with per-stream, per-peer, and global caps.
  • Evicts stale proposal streams instead of rejecting all new streams once caps are reached.
  • Rejects proposal parts too far ahead of the current height before persisting pending proposal data.
  • Tightens injected-transaction validation and refreshes the DB type metadata hash for the bounded payload changes.

Validator identity and peer-admission config was split to #5536.

Tests

  • rtk cargo nextest run -p ethexe-common db::tests::ensure_types_unchanged
  • rtk cargo nextest run -p ethexe-malachite-core
  • rtk cargo nextest run -p ethexe-malachite
  • rtk cargo clippy -p ethexe-malachite -p ethexe-malachite-core --all-targets -- -D warnings
  • rtk git diff --check origin/master...HEAD

@ukint-vs ukint-vs self-assigned this May 25, 2026
@ukint-vs ukint-vs requested a review from grishasobol May 25, 2026 20:22
@ukint-vs ukint-vs changed the title Bound Malachite proposal validation paths fix(malachite): tighten proposal validation bounds May 25, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request strengthens the security and stability of the Malachite validation path by enforcing resource constraints on injected transactions and proposal stream reassembly. Additionally, it updates the ethexe contracts to maintain compatibility with recent changes in vendored dependencies and helper APIs.

Highlights

  • Injected Transaction Validation: Added strict validation for injected transactions, including a cumulative encoded size cap per block and a check for duplicate transaction hashes.
  • Proposal Stream Management: Implemented per-peer and global caps on in-flight proposal streams and ensured immediate cleanup of completed streams to prevent unbounded state growth.
  • Contract Helper Migration: Updated Mirror and Router contracts to utilize the latest Foundry and frost helper APIs, alongside submodule pointer updates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ukint-vs ukint-vs added type: fix Bug fix correcting incorrect behavior scope: vara.eth Vara Ethereum application layer (L2) priority: important High priority, should be addressed soon labels May 25, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several security and correctness improvements to the ethexe module. In ethexe/malachite/core/src/streaming.rs, it resolves a potential denial-of-service vulnerability (unbounded memory growth) by introducing per-peer and total stream limits (MAX_STREAMS_PER_PEER, MAX_STREAMS_TOTAL) and automatically evicting malformed far-future streams. In ethexe/malachite/service/src/externalities.rs, it adds participant-side validation to reject blocks that exceed cumulative injected transaction size limits or contain duplicate injected transactions. Additionally, minor updates were made to the Solidity contracts to use Memory.writeWord and Hashes.efficientKeccak256 directly, and subproject commits for forge-std and frost-secp256k1-evm were updated. No review comments were provided, so there is no feedback to filter.

@ukint-vs ukint-vs changed the title fix(malachite): tighten proposal validation bounds fix(vara.eth): tighten Malachite proposal validation bounds May 28, 2026
@ukint-vs ukint-vs removed the priority: important High priority, should be addressed soon label May 28, 2026
@ukint-vs
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the security and robustness of the Malachite consensus engine in ethexe by introducing validator identities that bind Ethereum addresses to both secp256k1 public keys and libp2p peer IDs, allowing the engine to drop proposal parts from non-validator peers before buffering. Additionally, it implements strict resource limits on proposal streams (caps on stream messages, per-peer streams, and total streams with LRU eviction) to prevent denial-of-service attacks, and adds validation checks to reject blocks exceeding injected transaction size caps or containing duplicate transactions. There are no review comments, and I have no feedback to provide.

@ukint-vs ukint-vs force-pushed the vs/malachite-bounded-fixes branch from e2a4765 to d55ea36 Compare May 29, 2026 11:45
@ukint-vs ukint-vs changed the title fix(vara.eth): tighten Malachite proposal validation bounds fix(malachite): tighten proposal validation bounds May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: vara.eth Vara Ethereum application layer (L2) type: fix Bug fix correcting incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant